function Extension(){
	var linkMonitor = new LinkMonitor();	// LinkMonitor for monitoring page Links
	var detectedForms = new Array();		// HTML forms on the current page which have already been detected
	this.options = new Array();				// Extension options
	this.exceptions = new Array();			// Extension website exceptions (Ex: Do not setHTTPS www.facebook.com)
	this.compromised = false;				// Whether or not a malicious script was detected (In the LinkMonitor)

	
	/**
	 * TODO
	 * @author Daniel Fairweather
	 */
	this.initialize = function(){
		chrome.extension.sendMessage({method: "getOptions"}, storeOptions);
		// Check for new forms every 500ms
		setInterval(detectForms, 500);
        setTimeout(notify, 3000);
	}
	
	
	
	/**
	 * Detects new HTML forms on the current page and creates Link objects for 
	 * them. The Link objects are sent to the linkMonitor for analyzing and
	 * monitoring.
	 * @author Daniel Fairweather
	 */
	var detectForms = function(){
		var forms = new Array(); // The HTML forms on the current page
        
		// Get the forms on the current page
		forms = document.getElementsByTagName("form");
		
		// For each form, create and send a Link to the LinkMonitor
		for(var i = 0; i < forms.length; i++){ 	
			if(detectedForms.indexOf(forms[i]) == -1 && forms[i].getAttribute("action") != null){
				detectedForms.push(forms[i]);
                var link = new Link(forms[i]);
				linkMonitor.addLink(new Link(forms[i]));
			}
		}
	}
	
	
	
	/**
	 * TODO
	 * Should look a lot like get Notifications
	 */
	var getExceptions = function(exceptions){
		//this.exceptions = exceptions.data;
	}
	
	
	
	/**
	 * Asks the background page to display a notification with the effectiveness of CAT+S
	 * @author Sterling Rinehart
	 */
	var notify = function(){
        if(extension.options["notifications"] == true){
            var effectiveness = linkMonitor.getEffectiveness();
			// Don't notify the user if no links were found.
			var url = window.location.hostname;
			var allowance = 0;
			/*
			chrome.extension.sendMessage({method: "nExceptionCheck"}, function(response){
				for(var i=0; i < response.length; i++){
					if(response[i].indexOf(url) != -1){
						allowance++;
						}
					}
				});*/
						
			if(effectiveness.total != 0 /*|| allowance == 0*/){
				chrome.extension.sendMessage({method: "notify", safe: effectiveness.safe, total: effectiveness.total});
			}
        }
	}
	
	
	
	/**
	 *
	 */
	var storeOptions = function(input){
        var opt = input.data;
        extension.options["notifications"] = input.data[0];
    }
}

// Start the extension
this.extension = new Extension();
extension.initialize();